package com.lagou.homework;

public class ArrayToString {

    public static String toString(int[] arr) {
        if( arr == null)
            return "null";
       // int maxLen = arr.length - 1;

        //if (maxLen == -1)
        if(0 == arr.length)
            return "[]";


        StringBuilder sb1 = new StringBuilder();
        sb1.append("[");

        for (int i = 0; i < arr.length   ; i++) {
            if(i == arr.length - 1){
                sb1.append(arr[i]).append("]");
            } else{
                sb1.append(arr[i]).append(",");
            }
        }
        return sb1.toString();


    }
}
